/*
   @Copyright:LeetCode
   @Author:   tjyemail
   @Problem:  http://leetcode.com/problems/subsets
   @Language: C++
   @Datetime: 19-07-08 10:21
   */

class Solution {
	void backtrack(vector<int> &nums, int i, vector<int> &v, vector<vector<int> > &vs){
		vs.push_back(v);
		for(int j=i; j<nums.size(); ++j){
			v.push_back(nums[j]);
			backtrack(nums,j+1,v,vs);
			v.pop_back();
		}
	}
public:
	vector<vector<int>> subsets(vector<int>& nums) {
		vector<int> v;
		vector<vector<int> > vs;
		backtrack(nums,0,v,vs);
		return vs;
	}
};
